import { getTheme, setTheme } from "../storage.js";

let themeInstance = null;

const themeStore = function () {
  if (!themeInstance) {
    const state = {
      theme: getTheme(),
    };

    const getters = {
      getTheme() {
        return state.theme;
      },

      getTextColor() {
        return {
          light: "#000000",
          dark: "#ffffff",
        };
      },

      getInputBgColor() {
        return {
          light: "#fff",
          dark: "#45454e",
        };
      },

      getBubbleBgColor() {
        return {
          light: "#f0f0f0",
          dark: "#ffffff",
        };
      },

      getHomeCardBgColor() {
        return {
          light: "#f3f5fa",
          dark: "#45454e",
        };
      },

      getGuideBgColor() {
        return {
          light: "#fff",
          dark: "#45454e",
        };
      },
    };

    const setters = {
      setTheme(theme) {
        state.theme = theme;
        setTheme(theme);
      },
    };

    themeInstance = {
      getters,
      setters,
    };
  }

  return themeInstance;
};

export default themeStore;
